<template>
    <div style="width: 480px; height: 100px; margin: 20px auto;">
        <div class="input-num">
            <button @click="sub">上一页</button>
            <span>{{ num }}</span>
            <button @click="add">下一页</button>
        </div>
    </div>
</template>

<script>
module.exports = {
    data() {
        return {
            num: 2
        }
    },
    methods: {
        sub: function () {
            if (this.num > 1) {
                this.num--;
            } else {
                // alert("别点啦,太小啦!");
            }
        },
        add: function () {
            // console.log("add");
            // 累加
            if (this.num < 10) {
                this.num++;
            } else {
                alert("别点啦,太大啦!");
            }
        }
    }
}
</script>

<style>
.input-num {
    margin-top: 31px;
    height: 41%;
    display: flex;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 4px black;
}

.input-num button {
    width: 172px;
    height: 100%;
    font-size: 24px;
    color: gray;
    cursor: pointer;
    border: none;
    outline: none;
    background-color: black;
}

.input-num span {
    height: 50%;
    font-size: 35px;
    flex: 1;
    text-align: center;
    line-height: 47px;
}
</style>